import 'package:json_annotation/json_annotation.dart';
import 'package:smart_devices/utils/colors.dart';

part 'repair.g.dart';

@JsonSerializable()
class RepairModel {
  /// 标题
  String title;

  /// 维修号
  String orderNo;

  /// 设备名称
  String name;

  /// 设备编号
  String code;

  /// 设备存放位置
  String location;

  /// 紧急程度
  RepairDegreeEnum degree;

  /// 创建时间
  String addTime;

  /// 修改状态
  RepairStatusEnum status;

  RepairModel(
      {required this.title,
      required this.orderNo,
      required this.name,
      required this.code,
      required this.location,
      required this.degree,
      required this.addTime,
      required this.status});

  factory RepairModel.fromJson(Map<String, dynamic> json) =>
      _$RepairModelFromJson(json);

  Map<String, dynamic> toJson() => _$RepairModelToJson(this);

  @override
  String toString() {
    return toJson().toString();
  }
}

enum RepairDegreeEnum {
  slow(1, '低'),
  mid(2, '中'),
  fast(3, '急');

  final int value;
  final String label;

  const RepairDegreeEnum(this.value, this.label);
}

enum RepairStatusEnum {
  audit(1, '待审核', ColorsUtils.color0052),
  reject(2, '驳回', ColorsUtils.colorE34d),
  completed(3, '已完成', ColorsUtils.color2ba4),
  repair(4, '维修中', ColorsUtils.color005e);

  final int value;
  final String label;
  final String color;

  const RepairStatusEnum(this.value, this.label, this.color);
}
